<?php

namespace App\Admin\Controllers;

use App\Http\Controllers\Controller;
use App\Models\Contact;
use App\Models\MessageTemplate;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Widgets\Card;
use Dcat\Admin\Widgets\Checkbox;
use Dcat\Admin\Widgets\Radio;

class TestController extends Controller
{
    public function index(Content $content)
    {
        $name = 'contacts';
        $tmp = Contact::where('status', 1)->get();
        foreach ($tmp as $key => $value) {
            $options[$key] = "{$value['name']} {$value['phone']}";
        };
        // dd($options);
        $checkbox  = Checkbox::make($name, $options)->inline();

        $card = Card::make('选择联系人', $checkbox);

        $name_template = 'template';
        $options_template = MessageTemplate::where('status', 2)->pluck('content', 'id')->toArray();
        $radio = Radio::make($name_template, $options_template);
        $card_template = Card::make('选择模板', $radio);

        return $content
            ->header('发送短信')
            ->body($card)
            ->body($card_template);
    }
}
